// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DesignTimeHelper.cs" company="SmartPlan">
//   SmartPlan 2011
// </copyright>
// <summary>
//   http://stackoverflow.com/questions/2427381/how-to-detect-that-c-sharp-winform-code-is-executed-within-visual-studio
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace DbDiff.Common.Helper
{
    using System.ComponentModel;
    using System.Diagnostics;

    /// <summary>
    /// http://stackoverflow.com/questions/2427381/how-to-detect-that-c-sharp-winform-code-is-executed-within-visual-studio
    /// </summary>
    public static class DesignTimeHelper
    {
        public static bool IsInDesignMode
        {
            get
            {
                //return false;
                bool isInDesignMode = LicenseManager.UsageMode == LicenseUsageMode.Designtime || Debugger.IsAttached == true;

                if (!isInDesignMode)
                {
                    using (var process = Process.GetCurrentProcess())
                    {                        
                        return process.ProcessName.ToLowerInvariant().Contains("devenv");
                    }
                }

                return isInDesignMode;
            }
        }
    }
}